package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.service.CalidateCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/calidatecode")
@Api(tags = "统一短信验证码")
public class CalidateCodeController {
    @Autowired
    private CalidateCodeService calidateCodeService;

    /**
     * 手机号快速登录发送验证码
     */
    @GetMapping("/send4Login")
    @ApiOperation("手机号快速登录发送验证码")
    public Result send4Login(@RequestParam String telephone) {
        log.info("向{}发送验证码",telephone);
        boolean flag = calidateCodeService.send4Login(telephone);
        if (flag){
            return new Result(flag, "验证码发送成功",null);
        }
        return new Result(false, "验证码发送失败",null);
    }
}
